#ifndef SHOTMESSAGE_H_
#define SHOTMESSAGE_H_

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <string>
#include "ariba/ariba.h"
#include "../entities/Shot.h"

using namespace std;
using namespace ariba;
using std::string;

using_serialization;

class ShotMessage : public Message {
	VSERIALIZEABLE;

public:
	ShotMessage();
	ShotMessage(string player, float timestamp);
	virtual ~ShotMessage();
    string getPlayer() const;
    float getPositionX() const;
    float getPositionY() const;
    float getTimestamp() const;
    float getVelocityX() const;
    float getVelocityY() const;
    void setPlayer(string player);
    void setPositionX(float positionX);
    void setPositionY(float positionY);
    void setTimestamp(float timestamp);
    void setVelocityX(float velocityX);
    void setVelocityY(float velocityY);

private:
	string player;
	float positionX;
	float positionY;
	float velocityX;
	float velocityY;
	float timestamp;
};

sznBeginDefault( ShotMessage, X ) {
	std::stringstream ss;
	if (X.isSerializer()) {

		boost::archive::text_oarchive oa(ss);
		oa << positionX << positionY << velocityX << velocityY;
		string s = ss.str();
		uint32_t len = s.length();
		X && T(player) && len && T(s, len);
		//cout<<"Serialize: "<<s<<"\n";

	}else{
		uint32_t len;
		string s;
		X && T(player) && len;
		X && T(s, len);
		ss << s;
		boost::archive::text_iarchive ia(ss);
		ia >> positionX >> positionY >> velocityX >> velocityY;
		//cout<<"Deserialize: "<<s<<"\n";
		//cout<<"PositionX: "<<positionX<<" PositionY: "<<positionY<<" VelocityX: "<<velocityX<<"\n";
	}
} sznEnd();

#endif /* SHOTMESSAGE_H_ */
